<?php
/**
 * Create By: PhpStorm
 * User: yihua
 * File: RemoveUserAddress.php
 * Date: 2017/1/6
 * Time: 0:07
 */

namespace app\api\model\page\user;

use app\api\model\dao\UserAddress;
use app\library\PageBase;
use app\library\Error;

class RemoveUserAddress extends PageBase
{
    private $objUserAddressModel;

    public function __construct()
    {
        parent::__construct();
        $this->objUserAddressModel = new UserAddress();
    }

    public function excute($param)
    {
        $ret = $this->checkToken($param);
        if (false === $ret) {
            return $this->getRes(Error::ERR_SYS);
        }

        if (empty($param['user_id']) || empty($param['address_id'])) {
            return $this->getRes(Error::ERR_PARAM);
        }
        $res = $this->objUserAddressModel->removeAddress($param['user_id'], $param['address_id']);
        if ($res != 0) {
            return $this->getRes();
        } else {
            $this->data = $res;
            return $this->getRes(Error::ERR_USER_ADDRESS_REMOVE);
        }
    }
}



